package j2024.j202411;

import java.util.*;

public class j1104 {
    public static void main1(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        long[] arr = new long[n];
        for (int i = 0; i < n; i++) {
            arr[i] = in.nextLong();
        }
        Arrays.sort(arr);
        int left = 0,right = 1;
        int ret = Integer.MAX_VALUE;
        while(right<n){
            ret = (int) Math.min(arr[right]-arr[left],ret);
            right++;left++;
        }
        System.out.println(ret);
    }


    public static Set<Integer> set = new HashSet<>();
    public static void main2(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int[] arr = new int[n];
        for (int i = 0; i < n; i++) {
            arr[i] = in.nextInt();
        }
        Arrays.sort(arr);
        for (int i = n-1; i >=0; i--) {
            find(arr[i]);
        }
        int ret = 0;
        for (int i = 0; i < arr[0]; i++) {
            if(set.contains(i)){
                ret+=i;
                set.remove(i);
            }
        }
        System.out.println(ret);
    }
    public static void find(int x){
        for (int i = 2; i <x; i++) {
            if(x%i==0){
                if(isS(i)){
                    if(!set.contains(i)){
                        set.add(i);
                        break;
                    }
                }
            }
        }
    }
    public static boolean isS(int x){
        if(x==2){
            return true;
        }
        for (int i = 2; i <x; i++) {
            if(x%i==0){
                return false;
            }
        }
        return true;
    }

    /**
     *
     * 67. 二进制求和
     * 给你两个二进制字符串 a 和 b ，以二进制字符串的形式返回它们的和。
     * @param a
     * @param b
     * @return
     */
    public String addBinary(String a, String b) {
        StringBuilder sb = new StringBuilder();
        int lena = a.length()-1;
        int lenb = b.length()-1;
        int cou = 0;
        while(lena>=0 || lenb>=0 || cou!=0){
            if(lena>=0){
                cou+=(a.charAt(lena--)-'0');
            }
            if(lenb>=0){
                cou+=(b.charAt(lenb--)-'0');
            }
            sb.append((char)((char)(cou%2)+'0'));
            cou/=2;
        }
        return sb.reverse().toString();
    }
}
